---
title: "RecencySpace"
description: "Space for encoding timestamp data to measure item recency with time period configurations"
---

Recency space encodes timestamp type data measured in seconds and in unix timestamp format. Recency space is utilized to encode how recent items are. Use period_time_list to mark the time periods of interest.

Items older than the largest period_time are going to have uniform recency score. (0 or negative_filter if set)

You can use multiple period_times to give additional emphasis to sub time periods. Like using 2 days and 5 days gives extra emphasis to the first 2 days. The extent of which can be controlled with the respective weight parameters. Unit weights would give double emphasis on the first 2 days, 1 and 0.1 weights respectively would give tenfold importance to the first 2 days.

All items older than 5 days would get 0 or `negative_filter` recency score. Negative_filter is useful for effectively filtering out entities that are older than the oldest period time. You can think of the value of negative_filter as it offsets that amount of similarity stemming from other spaces in the index. For example setting it -1 would offset any text similarity that has weight 1 - effectively filtering out all old items however similar they are in terms of their text.

## Constructor

```python
RecencySpace(timestamp, time_period_hour_offset=timedelta(0), period_time_list=None, aggregation_mode=InputAggregationMode.INPUT_AVERAGE, negative_filter=0.0)
```

### Parameters

<ParamField path="timestamp" type="Timestamp | Sequence[Timestamp]" required>
A set of Timestamp objects. The actual data is expected to be unix timestamps in seconds. It is a SchemaFieldObject not regular python ints or floats.
</ParamField>

<ParamField path="time_period_hour_offset" type="timedelta" default="timedelta(0)">
Starting period time will be set to this hour. Day will be the next day of context.now(). Defaults to timedelta(hours=0).
</ParamField>

<ParamField path="period_time_list" type="list[PeriodTime] | PeriodTime | None" default="None">
A list of period time parameters. Weights default to 1. Period time to 14 days.
</ParamField>

<ParamField path="aggregation_mode" type="InputAggregationMode" default="InputAggregationMode.INPUT_AVERAGE">
The aggregation mode of the recency embedding. Possible values are: maximum, minimum and average. Defaults to InputAggregationMode.INPUT_AVERAGE.
</ParamField>

<ParamField path="negative_filter" type="float" default="0.0">
The recency score of items that are older than the oldest period time. Defaults to 0.0.
</ParamField>

## Inheritance

**Inheritance Chain**: 
- `RecencySpace` 
- → `Space`
- → `HasTransformationConfig` 
- → `HasLength`
- → `Generic`
- → `HasSpaceFieldSet`
- → `ABC`

## Properties

<ParamField path="allow_similar_clause" type="bool">
Whether this space allows similarity clauses in queries.
</ParamField>

<ParamField path="space_field_set" type="SpaceFieldSet">
The space field set for this recency space.
</ParamField>

<ParamField path="transformation_config" type="TransformationConfig[int, int]">
Configuration for transforming timestamp values into vectors.
</ParamField>